/*
 * @Author       : helishou
 * @Date         : 2021-05-17 09:08:33
 * @LastEditTime : 2021-06-23 14:37:54
 * @LastEditors  : helishou
 * @Description  : 多入口html-webpack-plugin
 * @FilePath     : \webpack入门\开发环境\2-打包html\webpack.config.js
 * 你用你的指尖,阻止我说再见,在bug完全失去之前
 */
const { resolve } = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  // 起点
  entry: {
    main: './src/index.js',
    header: './src/index2.js',
  },
  output: {
    filename: 'built.js',
    path: resolve(__dirname, 'build'),
  },
  // loader config
  module: {
    rules: [],
  },
  plugins: [
    // plugins config
    new HtmlWebpackPlugin({
      // 复制html文件，并自动引入打包输出的所有资源
      template: './src/index.html',
      filename: 'index.html',
      chunks: ['main'],
    }),
    new HtmlWebpackPlugin({
      // 复制html文件，并自动引入打包输出的所有资源
      template: './src/index2.html',
      filename: 'index2.html',
      chunks: ['header'],
    }),
  ],
  mode: 'development',
  //   mode:'production',
};
